<?php
/**
 * 匿名管理
 * Created by deng.
 * User: deng
 * Date: 2016/11/15
 * Time: 17:00
 */
class PinkAnonymous extends AdminBase{

    protected $do;

    function __construct(){
        parent::__construct();
        $this->do = 'anonymousManage';
        $this->{$this->op}();
    }

    function indexAction(){
        include_once template("admin_v2/anonymous");
        exit();
    }

    function hotreadyAction(){
        include_once template("admin_v2/anonymous_ready");
        exit();
    }

    function onlineAction(){
        include_once template("admin_v2/anonymous_online");
        exit();
    }

    function officialAction(){
        include_once template("admin_v2/anonymous_official");
        exit();
    }

    function autolineAction(){
        include_once template("admin_v2/anonymous_autoline");
        exit();
    }

    function listAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'list',
        ], $this->req));
    }

    //自动上线列表
    function onlinelistAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'onlinelist',
        ], $this->req));
    }

    //添加
    function addOnlineAction(){
        if ($this->req['bg_type']=='color'){
            $this->req['bg_value'] = str_replace('#', '', $this->req['bg_value']);
        }else{
            $parse_url = parse_url($this->req['bg_value']);
            $this->req['bg_value'] = $parse_url['path'];
        }
        $this->req['content'] = str_replace(' ', '', $this->req['content']);
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'addOnline',
        ], $this->req));
    }

    //删除
    function delOnlineAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate'=> 'delOnline',
            'bodyId' => $this->req['id'],
            'uid'    => $this->req['uid']
        ]);
    }

    //bodyId详情
    function detailOnlineAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'detailOnline',
            'id' => $this->req['id']
        ]);
    }

    //修改
    function editOnlineAction(){
        $parse_url = parse_url($this->req['bg_value']);
        $this->req['bg_value'] = $parse_url['path'];
        $this->req['content'] = str_replace(' ', '', $this->req['content']);
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'editOnline',
            'bodyId' => $this->req['bodyId'],
            'uid' => $this->req['uid'],
            'bg_type' => $this->req['bg_type'],
            'bg_value' => $this->req['bg_value'],
            'title' => $this->req['title'],
            'content' => $this->req['content'],
        ]);
    }

    function disdelOnlineAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'disdelOnline',
        ], $this->req));
    }

    function minuteOnlineAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'searchCommentOnline',
            'bodyId' => $this->req['cid'],
            'pos' => $this->req['pos'],
            'uid' => isset($this->req['uid']) ? $this->req['uid'] : 0
        ]);
    }

    function hotreadylistAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'hotready',
        ], $this->req));
    }

    function officiallistAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'official',
        ], $this->req));
    }

    function detailAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'detail',
            'id' => $this->req['id']
        ]);
    }

    function newAction(){
        if ($this->req['bg_type']=='color'){
            $this->req['bg_value'] = str_replace('#', '', $this->req['bg_value']);
        }else{
            $parse_url = parse_url($this->req['bg_value']);
            $this->req['bg_value'] = $parse_url['path'];
        }
        $this->req['content'] = str_replace(' ', '', $this->req['content']);
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'new',
        ], $this->req));
    }

    function dislistAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'disList',
        ], $this->req));
    }

    function disdelAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'disDel',
        ], $this->req));
    }

    function addAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'recAdd',
            'bodyId' => $this->req['bodyId'],
            'score' => $this->req['score'],
        ]);
    }

    function deleteAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'delete',
            'bodyId' => $this->req['id'],
            'uid' => $this->req['uid']
        ]);
    }

    function editAction(){
        $parse_url = parse_url($this->req['bg_value']);
        $this->req['bg_value'] = $parse_url['path'];
        $this->req['content'] = str_replace(' ', '', $this->req['content']);
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'edit',
            'bodyId' => $this->req['bodyId'],
            'uid' => $this->req['uid'],
            'bg_type' => $this->req['bg_type'],
            'bg_value' => $this->req['bg_value'],
            'title' => $this->req['title'],
            'content' => $this->req['content'],
        ]);
    }

    function editDetailAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'searchComment',
            'bodyId' => $this->req['cid'],
            'pos' => $this->req['pos'],
            'uid' => isset($this->req['uid']) ? $this->req['uid'] : 0
        ]);
    }

    function delhotreadyAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'delHotready',
            'bodyId' => $this->req['id'],
            'uid' => $this->req['uid']
        ]);
    }

    function delhotAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'recDel',
            'bodyId' => $this->req['id']
        ]);
    }

    function addhotreadyAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'upHotready',
        ], $this->req));
    }

    function delofficialAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'officialMan',
            'type' => 'del',
            'id' => $this->req['id']
        ]);
    }

    function addofficialAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'officialMan',
            'type' => 'add'
        ], $this->req));
    }

    function ready2lineAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'ready2line',
        ], $this->req));
    }

}

new PinkAnonymous;